<?php 
namespace Qwadmin\Controller;

class TongController extends ComController
{
	public function gong()

	{

		if (IS_POST) {
			
			// dump($_POST);
			$arr = $_POST;
			$arr['time'] = date('Y-m-d');
			$z_id = M('auth_group_access')->where(array('uid'=>$_SESSION['uid']))->select();
	      	$dada = M('member')->where(array('uid'=>$_SESSION['uid']))->select();
	      	$b_id = $z_id[0]['group_id'];
	      	$m_list = M('auth_group')->where(array('id'=>$b_id))->select();

	        // dump($m_list);
	        // exit;
	      	$arr['ment'] = $m_list[0]['title'];
	      	$arr['uname'] = $dada[0]['user'];
	      	if (M('gong')->add($arr) > 0 ) {
	      		echo '1111';
	      	}else{
	      		echo '2222';
	      	}
		}else{
			$this->display();
		}



		
	}








	public function can()
	{
		if (IS_POST) {
			$arr = $_POST;

			$arr['s_time'] = date('Y-m-d');
			$z_id = M('auth_group_access')->where(array('uid'=>$_SESSION['uid']))->select();
	      	$dada = M('member')->where(array('uid'=>$_SESSION['uid']))->select();
	      	$b_id = $z_id[0]['group_id'];
	      	$m_list = M('auth_group')->where(array('id'=>$b_id))->select();

	        // dump($m_list);
	        // exit;
	      	$arr['ment'] = $m_list[0]['title'];
	      	$arr['uname'] = $dada[0]['user'];
	      	$arr['aname'] = 'A:'.$_POST['aname'];
	      	$arr['bname'] = 'B:'.$_POST['bname'];

	      	if (M('can')->add($arr) > 0 ) {
	      		echo '1111';
	      	}else{
	      		echo '2222';
	      	}


		}else{
			$this->display();
		}
	}






	public function clist()
	{
		$dertime = date('Y-m-d');
		// echo $dertime;
		// exit;
		$clist = M('can')->where(['s_time'=>$dertime])->select();
		// dump($clist);
		// exit;
		$ctime = $clist[0]['time'];

		$ulist = M('ucan')->where(['s_time'=>$dertime])->select();
		// dump($ulist);
		// exit;
		// 
		$this->assign('ulist',$ulist);
		$this->display();
		
	}





	// public function list()
	// {
	// 	$this->display();
	// }





	public function z_export(){
       

         $dertime = date('Y-m-d');
        $ming = date('Y-m-d',strtotime('+1 day'));
        $hou = date('Y-m-d',strtotime('+2 day'));
		// echo $dertime;
		// exit;
		$clist = M('can')->where(['s_time'=>$dertime])->select();
		// dump($clist);
		// exit;
		$ctime = $clist[0]['time'];

		$ulist = M('ucan')->where(['time'=>['in',array($ming,$hou)]])->order('time desc')->select();
		// dump($ulist);
		// exit;

        if (!empty($ulist)) {
             
           //  dump($ulist);
           // exit;
                
            
        
            $tableHeader = array(
                '套餐','所属部门', '姓名', '时间'
            );
            $tableCols = array(
                'cname','ment','uname', 'time'
            );
            downloadExcel($ulist, $tableHeader,$tableCols, 'pcs'.'.xls');
        }else{
            $this->error('没有数据可以导出,请检查!');
            exit;
        }
    }






    public function del()
    {
    	// dump(I());
    	if (M('ucan')->where(['id'=>$_POST['id']])->delete() >0 ) {
    		echo '1111';
    	}else{
    		echo '2222';
    	}
    }







    public function guan()
    {
    	// echo '1';
    	// exit;
    	$time = date('Y-m-d');
    	// dump($time);
    	$off['off'] = '1';
    	if (M('can')->where(['s_time'=>$time])->save($off) > 0) {
    		echo '1111';
    	}else{
    		echo '2222';
    	}
    }










}